﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using cash_desk_model;
using cash_desk_model.src.model;

namespace cash_desk
{
    public partial class SoldProductsForm : Form
    {
        private String _paymentId;
        public SoldProductsForm(String paymentId)
        {
            this._paymentId = paymentId;
            InitializeComponent();
            this.initSoldProductsGrid();
        }

        private void initSoldProductsGrid()
        {
            this.soldProductsGrid.Rows.Clear();
            CashDeskService.SetupDBConn();
            CashDeskService service = new CashDeskService();
            List<Product> soldProducts = service.GetSoldProducts(this._paymentId);
            CashDeskService.DestroyDBConn();

            for (int i = 0; i < soldProducts.Count; i++)
            {
                this.soldProductsGrid.Rows.Add(
                    soldProducts[i].ProductName,
                    soldProducts[i].Code,
                    soldProducts[i].Type,
                    soldProducts[i].Price,
                    soldProducts[i].Quantity);
            }
            CashDeskService.DestroyDBConn();
        }
    }
}
